package com.sentinel.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import spring.cloud.Utils.R;

import java.io.Serializable;
import java.util.HashMap;

/**
 * @author cyt
 * @create 2020-06-06 8:46
 */
@RequestMapping("/provider")
@RestController
public class testController {

    @Value("${server.port}")
    private String serverPort;

    public static HashMap<Long, Payment> hashMap = new HashMap<Long, Payment>();

    static {
        hashMap.put(1L, new Payment(1L, "28a8c1e3bc2742d8848569891fb42181"));
        hashMap.put(2L, new Payment(2L, "bba8c1e3bc2742d8848569891ac32182"));
        hashMap.put(3L, new Payment(3L, "6ua8c1e3bc2742d8848569891xt92183"));
    }

    @GetMapping(value = "/paymentSQL/{id}")
    public R paymentSQL(@PathVariable("id") Long id) {
        Payment payment = hashMap.get(id);
        return R.ok().data("payment", payment);
    }


}

class Payment  implements Serializable {

    long id;
    String val;


    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getVal() {
        return val;
    }

    public void setVal(String val) {
        this.val = val;
    }

    public Payment(long id, String val) {
        this.id = id;
        this.val = val;
    }

    @Override
    public String toString() {
        return "Payment{" +
                "id=" + id +
                ", val='" + val + '\'' +
                '}';
    }
}